<?php
//$page['vars']['move'] = [{('id' => int)|('error' => string)}, 'coordinates' => array(int, int, int), 'units' => array(group => int, …), 'order' => string, 'resources' => U1_Removable_Resource|null, 'idPlanet' => int]
if (isset($page['vars']['move']))
{
	$vars = &$page['vars']['move'];

	if (isset($vars['error']))
	{
		echo '<new-moves><move order="'.$vars['order'].'" id-planet="'.$vars['idPlanet'].'"><error>'.$vars['error'].'</error>'.U1_Render::coordinates($vars['coordinates']);

		if ($vars['resources'])
			echo U1_Render::blocNodeGroup('resource', $vars['resources']);

		echo U1_Render::blocNodeGroup('unit', $vars['units']).'</move></new-moves>';
	}
	else
		echo '<new-moves><move id="'.$vars['id'].'/></new-moves>';
}

echo '<moves>';
foreach (U1_DAO_Move::selectLinkPlayer($player, 50) as $id => $moveUnits)
{
	$move = $moveUnits->getMove();
	U1_Render::addPlanet(
		$start = $move->getEndPoint()
	);
	U1_Render::addPlanet(
		$end = $move->getStartPoint()
	);

	echo '<move order="'.$move->getOrderName().'" id="'.$id.'" id-starting-planet="'.$start.'" id-end-planet="'.$end.'">';

	if ($move instanceof SW_Move_Transport)
		echo U1_Render::blocNodeGroup(
			'resource',
			$move->getRemovable('U1_Removable_Resource')->getQuantities()
		);

	echo U1_Render::blocNodeGroup('unit', $moveUnits->getUnits()).'</moves>';
}

echo '</moves>';